package org.mifos.boss.testwebservice;

import org.mifos.boss.webservice.ClientRequest;
import org.mifos.boss.webservice.ClientType;
import org.springframework.stereotype.Repository;
import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;

@Repository(value="person")
public class PersonImpl extends WebServiceGatewaySupport implements Person  {
	
	public PersonImpl() {
		}
	
	
	
	//WebServiceTemplate wsTemplate;	
	public void addPerson(String a, String b) {
		// TODO Auto-generated method stub
		ClientRequest cr = new ClientRequest();
		ClientType ct = new ClientType();
		ct.setFirstName(a);
		ct.setLastName(b);
		cr.setClient(ct);
		
		
		
		
		
		logger.debug("Calling web service template");
//		
//		getWebServiceTemplate().setDefaultUri("http://localhost:8080/mifos/webservices/");
//		
//		logger.debug("get default uri" + getWebServiceTemplate().getDefaultUri());
//		getWebServiceTemplate().marshalSendAndReceive(cr);
//		.sendSourceAndReceiveToResult("http://localhost:8080/mifos/webservices/", cr, null);
		getWebServiceTemplate().marshalSendAndReceive(cr);
//		getWebServiceTemplate().marshalSendAndReceive(cr, new WebServiceMessageCallback() {
//			
//			@Override
//			public void doWithMessage(WebServiceMessage message) throws IOException,
//					TransformerException {
//				// TODO Auto-generated method stub
//				 ((SoapMessage)message).setSoapAction("http://tempuri.org/Action");
//				 ((SoapMessage)message).getEnvelope().
//			}
//		});
//		
		
	}
	
	
	
	
}
